package com.zero;

/**
 * Created by aicaikeji on 2018/12/26.
 */
public class string_demo {
    public static void main(String[] args) {
        //字符串实例化
        String s1 = "我是菜鸟";
        System.out.println(s1);
        char[] charArr = {'a','b','f','c'};
        String s2 = new String(charArr);
        System.out.println(s2);
        //字符串长度
        System.out.println("s2的长度："+s2.length());
        //字符串拼接
        String s3 = s1.concat(s2);
        String s4 = s1 + s2;
        System.out.println(s3);
        System.out.println(s4);
        //字符串格式化
        String s5 = String.format("1234%d"+
        "上山打%s"+
        "哒哒哒哒",5,"老虎");
        System.out.println(s5);
        //	char charAt(int index)
        char c1 = s1.charAt(0);
        System.out.println(c1);
        //int compareTo(Object o)
        System.out.println(s1.compareTo(s2));

    }

}
